<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>选择楼栋</title>
<link href="${ctx}/styles/mainmenu2.css" rel="stylesheet"
	type="text/css">
<style>
.2td_listTable_record_off{
	background-color:#fefefe;
	padding-top:6px;
	padding-bottom:1px;
	padding-left:5px;

	cursor:pointer;
	vertical-align: top;
	}
.2td_listTable_record_on{
	background-color:#feec8c;
	padding-top:6px;
	padding-bottom:1px;
	padding-left:5px;
	cursor:pointer;
	}
</style>
<script language="JavaScript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript">
   var countNumber=0;

   function addNameTR(buildingId,areaName,buildingName)
    {
         var trArray = document.getElementsByName("nameTr");
         if(trArray){

            for (var i = 0; i < trArray.length; i++)
            {
                if(trArray[i].name==buildingId)return false;
            }

         }

        var table    = document.getElementById("tableBody");

        var tr = document.createElement('tr');
        tr.id = "nameTr";
        tr.name=buildingId;

        table.appendChild(tr);

        var td = document.createElement('td');
        tr.appendChild(td);
        var tempDivBuildingName="&nbsp;&nbsp;<div style=\"display:none\">"+buildingName+"</div>";
        var delHref = "<a href='javascript:void(0);' onclick=\"delTR(this);\"><img src='${ctx}/images/ico_delete.gif' alt='删除' width='16' height='16' border='0' align='absbottom'></a>";
        td.innerHTML = areaName + "(" + buildingName + ")&nbsp;&nbsp;" + delHref+tempDivBuildingName;
         document.getElementById("selectSpanMessage").style.display="none";
    }

    function delTR(link)
    {
         var table = document.getElementById("tableBody");
         table.removeChild(link.parentElement.parentElement);
    }

     function submitTable()
    {
        var trArray = document.getElementsByName("nameTr");

        var buildingIdStrTemp="";
        var buildingNameStrTemp="";
        if(trArray){

            for (var i = 0; i < trArray.length; i++)
            {
                var tr = trArray[i];
                buildingIdStrTemp=buildingIdStrTemp+""+tr.name+",";
                var tdArray = tr.getElementsByTagName("div");
                buildingNameStrTemp=buildingNameStrTemp+""+tdArray[0].innerHTML+",";
            }


        }

/*        if(buildingIdStrTemp==''){
         document.getElementById("selectSpanMessage").style.display="";

           return false;
        } else {
         document.getElementById("selectSpanMessage").style.display="none";

        }*/

        //parent.selectBuildingInfo(buildingIdStrTemp,buildingNameStrTemp);

         eval("findFrame('"+'${parentFrameId}'+ "')." + "selectBuildingInfo(buildingIdStrTemp,buildingNameStrTemp)");

          var table = document.getElementById("tableBody");
          do{
             if(trArray.length==0)break;
              table.removeChild(trArray[0]);
          }while(document.getElementsByName("nameTr"))

        windowClose();
    }

	function init(){
		<c:forEach var="isUsedBuilding" items="${isUsedBuildingListByPrecinct}" varStatus="status">
			addNameTR('${isUsedBuilding.keyword}','${isUsedBuilding.areaName}','${isUsedBuilding.name}');
		</c:forEach>
	}
</script>
</head>

<body onload="init();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="window_head_outBg">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td><span class="window_head_intext"><img
					src="${ctx}/images/ico_Advance.gif" align="absmiddle">&nbsp;选择楼栋</span></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="aux_header_line_1"></td>
	</tr>
	<tr>
		<td class="aux_header_line_2"></td>
	</tr>

	<tr>
		<td class="content">
		<table width="100%" border="0" align="center" cellpadding="0"
			cellspacing="0" class="outtable">
			<tr>
				<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td class="aux_outtable_color">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td>

								<table width="100%" border="0" cellpadding="0" cellspacing="1"
									class="aux_intable_color">

									<tr>
										<td colspan="2" class="aux_intable_td1">


										<table width="100%" border="0" align="center" cellpadding="0"
											cellspacing="0" class="outtable">

											<tr>
												<td valign="top">
												<div class="leftTree">
												<table width="100%" border="0" cellspacing="0"
													cellpadding="0">

													<tr>
														<td height="24">
														<table width="100%" border="0" cellspacing="0"
															cellpadding="0">
															<tr>
																<td>
																<table width="100%" border="0" cellspacing="0"
																	cellpadding="0">
																	<tr>
																		<td height="24">&nbsp;&nbsp;已选择的列表：<span
																			id="selectSpanMessage"
																			style="display:none;margin-left:10px;"> <img
																			src="${ctx}/images/validate/ErrorWarn.gif" width="15"
																			height="15" style="cursor: hand" alt="请选择一个楼栋"
																			onClick="alert('请选择一个楼栋');" /> </span></td>
																	</tr>
																	<tr>
																		<td>
																		<table width="100%" height="100" border="0"
																			cellpadding="0" cellspacing="1">
																			<tr>
																				<td align="left" valign="top" nowrap
																					class="LeftdownBlock1" style="padding:3px;">
																				<div
																					style="OVERFLOW: auto; WIDTH: 100%;  HEIGHT: 100%">
																				<table border="1" cellspacing="3" cellpadding="0"
																					id="table1" class="lastselect"
																					style="border-collapse:collapse"
																					bordercolor="BCBFD2">
																					<tbody id="tableBody">

																					</tbody>
																				</table>
																				</div>
																				</td>
																			</tr>
																		</table>
																		</td>
																	</tr>
																</table>
																</td>
															</tr>

														</table>
														</td>
													</tr>
												</table>
												</div>
												&nbsp;
												<div class="leftTree">
												<table width="100%" border="0" cellspacing="0"
													cellpadding="0">

													<tr>
														<td height="26">
														<table width="100%" border="0" cellspacing="0"
															cellpadding="0">
															<tr>
																<td>&nbsp;&nbsp;选择楼栋：</td>
															</tr>
														</table>
														</td>
													</tr>
													<tr>
														<td>

														<div style="height:128px;overflow:auto;">
														<table width="100%" height="100" border="0"
															cellpadding="0" cellspacing="1">
															<tr>
																<td align="left" valign="middle" nowrap
																	class="LeftdownBlock1" style="padding-top:3px;">
																<table width="99%" border="0" align="center"
																	cellpadding="0" cellspacing="1" class="room_border">
																	<tr>
																		<c:forEach var="buildingSelect"
																			items="${noUseBuildingList}" varStatus="status">
																			<td width="19%" class="2td_listTable_record_off"
																				id="${buildingSelect.keyword}"
																				ondblclick="addNameTR('${buildingSelect.keyword}','${buildingSelect.areaName}','${buildingSelect.name}');">${buildingSelect.areaName}(${buildingSelect.name})
																			</td>
																			<c:if test="${status.count%5==0}">
																	</tr>
																	<tr>
																		</c:if>
																		<c:if test="${status.last}">
																			<c:forEach var="emptyy" items="${emptyList}"
																				varStatus="emptyStatus">
																				<td width="19%" class="2td_listTable_record_off">&nbsp;</td>
																				<c:if
																					test="${(status.count+emptyStatus.count)%5==0}">
																	</tr>
																	<c:if test="${!emptyStatus.last}">
																		<tr>
																	</c:if>
																	</c:if>
																	</c:forEach>
																	</c:if>
																	</c:forEach>
																</table>
																</td>
															</tr>
														</table>
														</div>

														</td>
													</tr>
												</table>
												</div>
												</td>
											</tr>

										</table>
										</td>
									</tr>
								</table>
								</td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td colspan="2" class="window_footer">
		<table border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td>
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="buttonOffLeft" id="btn1_21"></td>
						<td class="buttonOffMiddle" id="btn1_22" onClick="submitTable();"
							onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)"
							onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif"
							alt="" width="14" height="14" border="0" align="absbottom">保存</td>
						<td class="buttonOffRight" id="btn1_23"></td>
					</tr>
				</table>
				</td>
				<td class="btn_between_space"></td>
				<td>
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="buttonOffLeft" id="btn1_31"></td>
						<td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();"
							onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"
							onBlur="btn_change(3)"><img
							src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14"
							border="0" align="absbottom">关闭</td>
						<td class="buttonOffRight" id="btn1_33"></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<p>&nbsp;</p>
		</td>
	</tr>
</table>

</body>
</html>
